<?php

class Security {
	
	function __construct() {
	}
	
	function getCurrentUser() {
		if (!isset($_SESSION['X_USER'])) {
			return  new User("guest", "", "Guest");
		}
		return $_SESSION['X_USER'];
	}
	
	function isCurrentUserGrantedWith($rid) {
		$user = Security::getCurrentUser();
		if ($user->username == "guest") {
			return false;
		}
		return in_array($rid, $user->getRoles());
	}
	
}
?>
	